package com.example.demo.controller;

import com.example.demo.dao.ClassRepository;
import com.example.demo.entity.classEntity;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.List;
import java.util.Optional;
import java.util.Scanner;

@RestController
public class ProIndexController {

    @Autowired
    ClassRepository cr;

    @RequestMapping("")
    public String index() {
        return "hello,fkg!";
    }

    @GetMapping("/queryClass")
    public String queryClass() {
        StringBuilder sb = new StringBuilder();
        List<classEntity> classEntities = cr.findAll();

        for (classEntity ce : classEntities) {
            sb.append(ce.toString());
            sb.append("\n");
        }

        System.out.println(sb.toString());

        return cr.findAll().toString();
    }

}
